transit_service_analyst demo

Import libraries

Create an instance of transit_service_analyst using a gtfs feed on file

The function get_lines_gdf() returns a GeodatFrame for each unique line by route, as determined by stop pattern. A trip_id representing each stop pattern is used as the unique ID and is called rep_trip_id. Show the first five rows:

Function to map line geometry

Let's map one line for each route:

The field transit_type is included so, for example, we can plot all routes that are not bus.

The function get_tph_by_line() returns a DataFrame with hourly frequencies for each rep_trip. Show the first 5 rows:

Use get_tph_by_line() to get all rep_trips that have frequent service of 4 or more trips per hour during peak hours.

The get_line_stops_gdf() function returns a GeoDataFrame consisting of the sequence of stops for each route returned by get_lines_gdf(). Use it and stops property to get the stops associated with the frequent routes.

The function get_tph_at_stops() function returns a DataFrame of total trips at each stop, independent of route. Let's use it to map stops by total number of trips for the AM peak:

Let's use GeoPandas buffering function to buffer these stops by 1/4 mile.